package com.dq.domain.statistics;

import com.dq.domain.sys.user.user.BossUser;
import com.dq.domain.sys.user.user.WxUser;
import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.org.Org;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;

/**
 * @author liuhui
 * @date 2019/11/29 0029 16:11:11
 */
@Data
@Entity
@ApiModel("统计消费排行榜")
public class Statistics extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("统计日期，表示统计的哪一天")
    protected Long countTime;

    @ApiModelProperty("门店")
    @ManyToOne
    protected WxUser wxUser;

    @ApiModelProperty("门店")
    @ManyToOne
    protected Org org;

    @ApiModelProperty("员工")
    @ManyToOne
    protected BossUser staffUser;

    @ApiModelProperty("统计类型")
    @Enumerated(EnumType.ORDINAL)
    protected StatisticsType statisticsType;

    @ApiModelProperty("销售额")
    protected BigDecimal salePrice;

    public enum StatisticsType{
        product("产品"),project("项目"),customer("顾客"),salePrice("销售额");
        public String name;

        StatisticsType(String name){
            this.name = name;
        }
    }

    public Statistics(){

    }
    public Statistics(Long countTime,Long number,Org org,StatisticsType statisticsType){
        this.countTime = countTime;
        this.org = org;
        this.statisticsType = statisticsType;
    }
    public Statistics(Long countTime,Long number,Org org,StatisticsType statisticsType,BigDecimal salePrice){
        this.countTime = countTime;
        this.org = org;
        this.statisticsType = statisticsType;
        this.salePrice = salePrice;
    }
    @Data
    @ApiModel("统计视图")
    public static class Vo implements VO{
        protected Long id;

        protected String countTime;

        protected Long number;
    }


    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.countTime = fmt(this.getCountTime(), TimeUtil.YYYY_MM_DD_HH_MM_SS);
        return vo;
    }
}
